package com.chinasoft.ssm.service.impl;

import com.chinasoft.ssm.mapper.UserInfoMapper;
import com.chinasoft.ssm.pojo.User;
import com.chinasoft.ssm.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Autowired
    UserInfoMapper mapper;

    @Override
    public Boolean login(String name, String password) {
        User info = mapper.selectByName(name);
        // 数据查询不到
        if (info == null) {
            log.info("cheng11");
            return false;
        }
        // 比较密码
        if (password.equals(info.getPassword())) {
            log.info("chengg");
            return true;
        } else {
            log.info("cheng");
            return false;
        }
    }

    @Override
    public Boolean changePW(String username, String password) {
        return null;
    }

    @Override
    public List<User> selectAll() {
        return mapper.selectall();
    }

    @Override
    public User selectone(String name) {
        return mapper.selectByName(name);
    }

    @Override
    public User selectById(int id) {
        return mapper.selectById(id);
    }

    @Override
    public Integer update(User user) {
        return mapper.update(user);
    }

    @Override
    public Integer deleteById(Integer id) {
        return mapper.delete(id);
    }

    @Override
    public List<User> selectByDSql(User user) {
        return mapper.selectByDSql(user);
    }

    @Override
    public Integer add(User user) {
        return mapper.add(user);
    }
}
